package descentFly.weaponts.element
{
	import away3d.materials.ColorMaterial;
	import away3d.materials.MaterialBase;
	import away3d.primitives.Cylinder;
	
	import descentFly.away3D4.chips.df_chipAway;
	import descentFly.chips.df_chip;
	import descentFly.weaponts.df_pulseElement;
	
	import space.sp_utils;
	
	public class df_laserElement extends df_pulseElement {
		public static const FIELD_RADIUS: String		= 'radius';
		public static const FIELD_COLOR: String 		= 'color';
		public static const FIELD_ALPHA: String 		= 'alpha';
		public static const FIELD_LENGTH: String 		= 'length';
		
		public static const DEFAULT_RADIUS	: Number	= 2;
		public static const DEFAULT_COLOR	: uint 		= 0xFFFFFF;
		public static const DEFAULT_ALPHA	: Number 	= 1;
		public static const DEFAULT_LENGTH	: Number 	= DEFAULT_RADIUS * 10;
		
		public function df_laserElement(a_chip: df_chipAway, a_options:Object) {
			sp_utils.checkParam(a_options, FIELD_RADIUS, DEFAULT_RADIUS);
			sp_utils.checkParam(a_options, FIELD_COLOR, DEFAULT_COLOR);
			sp_utils.checkParam(a_options, FIELD_ALPHA, DEFAULT_ALPHA);
			sp_utils.checkParam(a_options, FIELD_LENGTH, DEFAULT_LENGTH);
			super(a_chip, a_options);
		}
		
		protected function createMaterial(): MaterialBase {
			return new ColorMaterial(options.color, options.alpha);
		}
		
		override protected function initialize():void {
			super.initialize();
			var cyl: Cylinder = new Cylinder(createMaterial(), options.radius, options.radius, options.length, 4);
			cyl.rotationX = 90;
			addChild(cyl);
		}
	}
}